/*********************************************************************************
Organization 					: 				Georgia Institute of Technology
  
Institute 						:				Cognitive Computing Group(CCL)
 
Authors							: 				Santiago Ontanon
 												
Class							:				UnitKilledSoftCondition
 
Function						: 				Provides a class for holding a 
												condition that specifies whether 
												a unit was killed or not
****************************************************************************/
package planninglanguage.softconditions;

import org.w3c.dom.DOMException;

import base.WargusGameState;
import base.WargusStateImporter;
import base.WargusUnit;

public class UnitKilledSoftCondition extends SoftCondition {

	int m_unitID;
	
	public UnitKilledSoftCondition(int a_unitID)
	{
		m_unitID = a_unitID;
	}
	public String toString(int tabs)
	{
		String n = super.toString(tabs);
		n = n + "Unit Id is" + m_unitID;
		return n;
	}
	public float test(WargusGameState a_gameState) throws NumberFormatException, DOMException
	{
		WargusUnit u = a_gameState.getUnit(m_unitID);

		if (u==null) return 1.0f;
		
		float tmp = ((float)(u.getHitPoints()) / ((float)(WargusStateImporter.unitMaxHitPoints(u.getType()))));
		return 1.0f-tmp;
	}
	
}
